<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <title>后台登录</title>
    <link href="/res/css/admin_login.css" type="text/css" rel="stylesheet">

</head>
<body>

<div class="login">
    <div class="message">商城后台管理系统</div>
    <div id="darkbannerwrap"></div>

    <form method="" role="form" action="">
        <input name="username" placeholder="用户名" required="" type="text">
        <hr class="hr15">
        <input name="password" placeholder="密码" required="" type="password">
        <hr class="hr15">
        <input value="登录" style="width:100%;" type="button" id="login">
        <hr class="hr20">
    </form>

</div>

<div class="copyright"></div>

<script src="${base}/res/plugins/hplus/js/jquery.min.js"></script>
<script type="text/javascript" src="${base}/res/plugins/hplus/js/plugins/layer/layer.min.js"></script>
<script type="text/javascript">
    $(function () {
        window.document.onkeypress=SubmitOrHidden;//当有键按下时执行函数
    });

    //这个就是键盘触发的函数
    var SubmitOrHidden = function(evt){
        evt = window.event || evt;
        if(evt.keyCode ==13){//如果取到的键值是回车
            login();
        }else{
            //其他键  dosomething
        }
    }

    $("#login").click(function () {
        login();
    });
    function login() {
        var username=$("input[name='username']").val();
        var password=$("input[name='password']").val();
        $.ajax({
            url:"/admin/singIn",
            type:"POST",
            data:{
                username:username,
                password:password
            },
            success:function (data) {
                console.log(111111);
                alert(data.state);
                if(data.state=='ok'){
                    window.location.href="/member";
                }else{
                    layer.msg(data.info);
                }
            }
        })
    }
</script>
</body>
</html>